import { DataTypes } from 'sequelize'
const seq = require('../db/seq')

const UnivModels:any = seq.define('univ', {
  id: {
    autoIncrement: true,
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true
  },
  school_id: {
    type: DataTypes.STRING(20),
    allowNull: false,
    comment: "学校标识码",
    unique: "school_id_UNIQUE"
  },
  school_name: {
    type: DataTypes.STRING(255),
    allowNull: false
  },
  city_id: {
    type: DataTypes.INTEGER,
    allowNull: true,
    references: {
      model: 'region',
      key: 'id'
    }
  },
  province_name: {
    type: DataTypes.STRING(255),
    allowNull: true,
    comment: "省名，由触发器生成"
  },
  city_name: {
    type: DataTypes.STRING(255),
    allowNull: true,
    comment: "城市名，由触发器生成"
  },
  level: {
    type: DataTypes.STRING(255),
    allowNull: true
  },
  department: {
    type: DataTypes.STRING(255),
    allowNull: true,
    comment: "主管部门"
  },
  other: {
    type: DataTypes.STRING(255),
    allowNull: true
  },
  creattime: {
    type: DataTypes.DATEONLY,
    allowNull: true,
    comment: "建立时间，由触发器生成"
  },
  moditime: {
    type: DataTypes.DATEONLY,
    allowNull: true,
    comment: "修改时间，由触发器生成"
  },
  introduction: {
    type: DataTypes.STRING(255),
    allowNull: true,
    defaultValue: "略",
    comment: "高校简介"
  }
}, {
  tableName: 'univ',
  hasTrigger: true,
  timestamps: false,
  indexes: [
    {
      name: "PRIMARY",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "id" },
      ]
    },
    {
      name: "school_id_UNIQUE",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "school_id" },
      ]
    },
    {
      name: "index3",
      using: "BTREE",
      fields: [
        { name: "city_id" },
      ]
    },
  ]
});

module.exports = UnivModels